package com.tenglong.teacher.ui.adapter.viewholder;

import android.view.View;
import android.widget.TextView;

import com.tenglong.teacher.R;
import com.tenglong.teacher.data.resultInfo.DateInfo;
import com.tenglong.teacher.ui.adapter.DateInfoAdapter;
import com.tenglong.teacher.ui.adapter.viewholder.base.BaseViewHolder;

public class SeleViewHolder extends BaseViewHolder<DateInfo> {
    private TextView date;
    private DateInfoAdapter.DateItemListener listener;
    private DateInfo info;

    public SeleViewHolder(View itemView) {
        super(itemView);
        initView();
        setListener();
    }

    public SeleViewHolder(View itemView, DateInfoAdapter.DateItemListener listener) {
        this(itemView);
        this.listener = listener;
    }

    private void setListener() {
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onDateItemListener(info, getLayoutPosition());
                }
            }
        });
    }

    private void initView() {
        date = itemView.findViewById(R.id.tv);
    }

    @Override
    public void setLayoutInfo(DateInfo info) {
        this.info = info;
        date.setText(info.date);
        date.setSelected(info.isSele);
    }
}
